# Maintainer: Jürgen Hötzel <juergen@archlinux.org>

_pkgname=rresult
pkgname=ocaml-${_pkgname}
pkgver=0.7.0
pkgrel=1
pkgdesc="OCaml module for handling computation results and errors in an explicit and declarative manner"
arch=('loong64' 'x86_64')
url="https://erratique.ch/software/rresult"
license=('ISC')
depends=('ocaml')
makedepends=('ocaml-findlib' 'ocamlbuild' 'ocaml-topkg' 'opam')
options=('!strip')
source=("https://erratique.ch/software/rresult/releases/rresult-${pkgver}.tbz")
sha256sums=('11aa7f5b83460e60431e3154e3e32c071d46e151ea5760cf24377805bf975540')

build() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  ocaml pkg/pkg.ml build --dev-pkg false
}

package() {
  cd "${srcdir}/${_pkgname}-${pkgver}"
  opam-installer --prefix="$pkgdir/usr" --libdir='lib/ocaml' --docdir='share/doc'

  mv "${pkgdir}/usr/share/doc/${_pkgname}" "${pkgdir}/usr/share/doc/${pkgname}"
  install -dm755 "$pkgdir/usr/share/licenses/$pkgname"
  ln -sf "/usr/share/doc/$pkgname/LICENSE.md" "$pkgdir/usr/share/licenses/$pkgname/LICENSE.md"
}
